

public class Test {
    public static  int count =0;

    public static void main(String[] args) {
        int [ ] arr = {1,2,3,4};

        //求数组长度
        int len = arr.length;
        System.out.println(len);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        System.out.println(arr[3]);
        // System.out.println(arr[123]);
        //当给了个大值时，会出现数组下标越界异常

    }

    public static void main5(String[] args) {
        //定义数据的三组方式
        int [ ] arr = {1,2,3,4};
        //  int arr [] = {1,2,3,4}//不建议哈
         int [] arr2 = new int []{12,3,4,5};
         //new 是关键子，  一般用来 new对象
         int []arr3 =new int [ 10];  //没有初始化   只是分配了内存   其中存储的全是 0；
    }



    public static  int fib2(int n){
        if( n == 1|| n == 2){
            return 1;
        }
        int f1 = 1;
        int f2 = 1;
        int f3 = 1;
        for(int i=3;i <=n;i++){
            f3 = f1+f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }


    public static int fib (int n){

        if( n == 1||n == 2){
            return  1;
        }
        if(n == 3){
            count++;
        }
        return fib(n-1)+fib(n-2);

    }
    public static void main3(String[] args) {

        System.out.println(fib(40));
        System.out.println(count);
        System.out.println(fib2(40));

    }

    public static int ssun(int n){
        if(n ==1){
            return n;
        }
        int sum = n+ssun(n-1);
        return sum;

    }
    public static void print(int n){
        if(n<10){
            System.out.println(n%10);
            return;
        }
        print(n/10);
        System.out.println(n%10);
    }
    public static void main2(String[] args) {
        int n = 1234;
        ssun(n);
    }
    public static int factor(int x){
        if(x == 1){
            return 1;
        }
        int ate = x * factor(x-1);
        return ate;
    }
    public static void main1(String[] args) {
        int n =5;
        int ret = factor(n);
        System.out.println(n);

    }

}
